class Solution {
public:
    ListNode* removeNthFromEnd(ListNode* head, int n) {
        int len=0;
        for(auto p=head;p!=NULL;p=p->next)
            len++;
        auto newhead=new ListNode(0,head);
        int i=1;//注意是1哦
        auto p=newhead;//依赖于前驱
        for(;i<len-n+1;i++,p=p->next)
        {
            ;
        }
        p->next=p->next->next;
        return newhead->next;

    }
};